/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package smary.ejb.stateful;

import javax.ejb.EJB;
import javax.ejb.Stateful;
import javax.ejb.Stateless;
import javax.inject.Inject;
import smary.ejb.entity.Userloginaccount;
import smary.ejb.stateless.auto.UserloginaccountFacade;




/**
 * Speichert die Anmeldedaten der aktuellen Session. Kann ausserdem
 * die Anmeldedaten Prüfen über die UserloginaccountFacade welche per Dependency
 * Injection instanziiert wird.
 * @author Alex
 */
@Stateless
public class LoginService implements LoginServiceLocal {
    

    private String username;
    private String password;
    
    @Inject
    UserloginaccountFacade ufl;

    public Userloginaccount getAccount() {
        return checkLogin();
    }


    
    @Override
    public void doLogin(String username, String password) {
        this.username = username;
        this.password = password;
        checkLogin();
    }
    Userloginaccount checkLogin(){
        if(username!=null && password != null)
       return ufl.checkLoginData(username, password);
       return null;
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    @Override
    public void logOut() {
        username = null;
        password = null;
    }
    
}
